package com.aspose.cells;

import java.util.ArrayList;
import java.util.Iterator;

class zbre extends zbz {
   private ArrayList a;

   zbre() {
      this.c(181);
   }

   void a(ArrayList var1) {
      this.a = null;
      if (var1 != null && var1.size() != 0) {
         int[] var2 = (int[])((int[])var1.get(0));
         int var3 = var2.length * 2;
         int var4 = 8224 / var3;
         int var5 = 8224 % var3;
         int var6 = 0;
         if (var4 >= var1.size()) {
            this.a((short)(var3 * var1.size()));
            this.c = new byte[this.d()];

            for(Iterator var17 = var1.iterator(); var17.hasNext(); var6 += var3) {
               int[] var18 = (int[])var17.next();
               a(var18, this.c, var6);
            }

         } else {
            byte[] var7;
            int var8;
            int var11;
            if (var5 == 0) {
               this.a = new ArrayList();
               var7 = null;

               for(var8 = 0; var8 < var1.size(); ++var8) {
                  if (var8 == 0) {
                     this.a((short)(var4 * var3));
                     this.c = new byte[this.d()];
                     var7 = this.c;
                  } else if (var8 % var4 == 0) {
                     zmo var9 = new zmo();
                     int var10 = var1.size() - var8;
                     var11 = (var10 > var4 ? var4 : var10) * var3;
                     var7 = new byte[var11];
                     var9.b(var7);
                     com.aspose.cells.b.a.a.ze.a(this.a, (Object)var9);
                     var6 = 0;
                  }

                  a((int[])((int[])var1.get(var8)), var7, var6);
                  var6 += var3;
               }
            } else {
               this.a = new ArrayList();
               var7 = null;
               var8 = 0;

               for(int var16 = 0; var16 < var1.size(); ++var8) {
                  label70: {
                     if (var16 == 0) {
                        this.a((short)8224);
                        this.c = new byte[this.d()];
                        var7 = this.c;
                     } else if (var8 == var4) {
                        int[] var19 = (int[])((int[])var1.get(var16));

                        for(var11 = 0; var11 < var5 / 2; ++var11) {
                           System.arraycopy(com.aspose.cells.b.a.zc.a(var19[var11]), 0, var7, var6, 2);
                           var6 += 2;
                        }

                        zmo var12 = new zmo();
                        int var13 = var3 - var5;
                        var8 = -1;
                        var4 = (8224 - var13) / var3;
                        var5 = (8224 - var13) % var3;
                        int var14 = var1.size() - var16 - 1;
                        int var15 = var14 > var4 ? 8224 : var14 * var3 + var13;
                        var7 = new byte[var15];
                        var12.b(var7);
                        com.aspose.cells.b.a.a.ze.a(this.a, (Object)var12);
                        var6 = 0;

                        while(true) {
                           if (var11 >= var19.length) {
                              break label70;
                           }

                           System.arraycopy(com.aspose.cells.b.a.zc.a(var19[var11]), 0, var7, var6, 2);
                           var6 += 2;
                           ++var11;
                        }
                     }

                     a((int[])((int[])var1.get(var16)), var7, var6);
                     var6 += var3;
                  }

                  ++var16;
               }
            }

         }
      } else {
         this.b(8);
         this.c = new byte[this.d()];
      }
   }

   static void a(int[] var0, byte[] var1, int var2) {
      for(int var3 = 0; var3 < var0.length; ++var3) {
         if (var0[var3] != 0) {
            System.arraycopy(com.aspose.cells.b.a.zc.a(var0[var3]), 0, var1, var2, 2);
         }

         var2 += 2;
      }

   }

   void a(zqa var1) throws Exception {
      super.a(var1);
      if (this.a != null) {
         Iterator var2 = this.a.iterator();

         while(var2.hasNext()) {
            zmo var3 = (zmo)var2.next();
            var3.a(var1);
         }
      }

   }
}
